package com.shuang.string5;

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        //先整体反转 再将分成两个区间分别反转两个区间

        Scanner sc = new Scanner(System.in);

        //输入一个整数和一个字符串
        int k = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();

        char[] strArr = s.toCharArray();

        //字符串进行整体反转
        reverseString(strArr, 0, s.length() - 1);

        //两个区间分别反转0~k-1 和 k~length-1
        reverseString(strArr, 0, k-1);
        reverseString(strArr, k, s.length() - 1);

        System.out.println(strArr);
    }

    //定义方法 反转字符串区间[start, end]
    public static void reverseString(char[] strArr, int start, int end){

        while (start < end){
            char temp = strArr[start];
            strArr[start] = strArr[end];
            strArr[end] = temp;
            start++;
            end--;
        }
    }
}
